CentOS 6
Sponsored Link

Func - CommandModule
2011/07/15
 
Basic usage of CommandModule. It's possible to do most operations with this module.
[1] Run 'yum update' on all minions.
[root@certmaster ~]#
func "*" call command run "yum -y update" | sed 's/\\n/\n/g'
('minion02', [0, 'Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp Setting up Update Process No Packages marked for Update ', '']) ('minion01', [0, 'Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp Setting up Update Process No Packages marked for Update ', ''])
[2] Execute 'ls -l /root' on all minions.
[root@certmaster ~]#
func "*" call command run "ls -l /root" | sed 's/\\n/\n/g'
('minion02', [0, 'total 20 -rw-------. 1 root root 1274 Jul 15 21:58 anaconda-ks.cfg -rw-r--r--. 1 root root 8681 Jul 15 21:58 install.log -rw-r--r--. 1 root root 3094 Jul 15 21:56 install.log.syslog ', '']) ('minion01', [0, 'total 20 -rw-------. 1 root root 1274 Jul 15 21:58 anaconda-ks.cfg -rw-r--r--. 1 root root 8681 Jul 15 21:58 install.log -rw-r--r--. 1 root root 3094 Jul 15 21:56 install.log.syslog ', ''])
[3] Execute 'cat /etc/passwd' on a minion.
[root@certmaster ~]#
func "minion01" call command run "cat /etc/passwd" | sed 's/\\n/\n/g'
('minion01', [0, 'root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin gopher:x:13:30:gopher:/var/gopher:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin saslauth:x:499:499:"Saslauthd user":/var/empty/saslauth:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin fermi:x:500:500::/home/fermi:/bin/bash ntp:x:38:38::/etc/ntp:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin haldaemon:x:68:68:HAL daemon:/:/sbin/nologin smolt:x:498:498:Smolt:/usr/share/smolt:/sbin/nologin ', ''])
[4] Execute 'touch test.txt' on all minion.
[root@certmaster ~]#
func "*" call command run "touch /root/test.txt"

('minion02', [0, '', ''])
('minion01', [0, '', ''])
[root@certmaster ~]#
func "*" call command run "ls -l /root" | sed 's/\\n/\n/g'
('minion02', [0, 'total 20 -rw-------. 1 root root 1274 Jul 15 21:58 anaconda-ks.cfg -rw-r--r--. 1 root root 8681 Jul 15 21:58 install.log -rw-r--r--. 1 root root 3094 Jul 15 21:56 install.log.syslog -rw------- 1 root root 0 Jul 15 23:04 test.txt ', '']) ('minion01', [0, 'total 20 -rw-------. 1 root root 1274 Jul 15 21:58 anaconda-ks.cfg -rw-r--r--. 1 root root 8681 Jul 15 21:58 install.log -rw-r--r--. 1 root root 3094 Jul 15 21:56 install.log.syslog -rw------- 1 root root 0 Jul 15 23:04 test.txt ', ''])
[5] Execute Changing owner and permission for test.txt on all minion.
[root@certmaster ~]#
func "*" call command run "chown nobody. /root/test.txt;chmod 600 /root/test.txt"

('minion02', [0, '', ''])
('minion01', [0, '', ''])
[root@certmaster ~]#
func "*" call command run "ls -l /root/test.txt" | sed 's/\\n/\n/g'
('minion02', [0, '-rw------- 1 nobody nobody 0 May 14 23:04 /root/test.txt ', '']) ('minion01', [0, '-rw------- 1 nobody nobody 0 May 14 23:04 /root/test.txt ', ''])
[6] Restart ntpd on all minions.
[root@certmaster ~]#
func "*" call command run "service ntpd restart" | sed 's/\\n/\n/g'
('minion02', [0, 'Shutting down ntpd: [ OK ] Starting ntpd: [ OK ] ', '']) ('minion01', [0, 'Shutting down ntpd: [ OK ] Starting ntpd: [ OK ] ', ''])
 
Tweet